package com.zzxy.springmvc.controller;

import com.zzxy.springmvc.po.Student;
import com.zzxy.springmvc.po.StudentExt;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/stu")
public class StudentController {
    @RequestMapping("register")
    public String register(){
        return "/user/register";
    }

    @RequestMapping("insert")
    public @ResponseBody Student insert(@RequestBody Student student){
        student.setPassword(student.getPassword()+":qwe");
        student.setUsername(student.getUsername()+":asd");
        //service > MyBatis
        return student;
    }

    @RequestMapping("/addStu")
    public String addStu(String username,String password){
        System.out.println(username);
        System.out.println(password);
        //service > dao >insert into student...
        return "/user/userList";
    }
    @RequestMapping("/addStu1")
    public String addStu1(Student student){
        System.out.println(student);
        //service > dao >insert into student...
        return "/user/userList";
    }
    @RequestMapping("/addStu2")
    public String addStu2(StudentExt ext){
        //System.out.println(ext);
//     for(Student student:ext.getStudentList())
            System.out.println(ext);
        //service > dao >insert into student...
        return "/user/userList";
    }
    @RequestMapping("test")
    public String test(){
        return "forward:/register.do";
    }

    @RequestMapping("test1")
    public  String  test1(){
        return "redirect:/register.do";
    }
}
